namespace NHCodeFirst
{
    using System;

    internal static class EntityInspector
    {
        public static void Inspect(Type entityType)
        {
            if (!NHibernateConfiguration.MappingModels.ContainsKey(entityType))
                NHibernateConfiguration.AddToMapModels(entityType);
            var hibernateMapping = NHibernateConfiguration.MappingModels[entityType];
            if (entityType.BaseType != null && entityType.BaseType != typeof (Object))
            {
                if (!NHibernateConfiguration.MappingModels.ContainsKey(entityType.BaseType))
                    NHibernateConfiguration.AddToMapModels(entityType.BaseType);
                NHibernateConfiguration.MappingModels[entityType.BaseType].Class.SubTypesCount++;
                hibernateMapping.Class.ElementType = "union-subclass";
                hibernateMapping.Class.Extends = entityType.BaseType.Name;
            }
            else
                hibernateMapping.Class.ElementType = "class";
        }
    }
}